#include <OgreMath.h>
#include <OgrePrerequisites.h>

#define DLL_EXPORT __declspec(dllexport)

using namespace Ogre;

extern "C" DLL_EXPORT Radian *getRadian(float r)
{
	return new Radian(r);
}

extern "C" DLL_EXPORT Radian *op_Radian_Unary(Radian *rad, char op)
{
	switch(op)
	{
	case '+':
		return new Radian(+(*rad));
	case '-':
		return new Radian(-(*rad));
	default:
		return rad;
	}
}

extern "C" DLL_EXPORT Radian *opRadian_Radian_Binary_Radian(Radian *rad1, const char *op, Radian *rad2)
{
	unsigned int _op = op[1] ? op[0] + op[1] : op[0];  //Should be null terminated.
	switch(_op)
	{
	case '=':
		*rad1 = *rad2;
		return rad1;
	case '+':
		return new Radian(*rad1 + *rad2);
	case '-':
		return new Radian(*rad1 - *rad2);
	case '*':
		return new Radian(*rad1 * *rad2);
	case '+'+'=':
		*rad1 += *rad2;
		return rad1;
	case '-'+'=':
		*rad1 -= *rad2;
		return rad1;
	default:
		return rad1; //Nothing much to do here
	}
}

extern "C" DLL_EXPORT bool opBool_Radian_Binary_Radian(Radian *rad1, char *op, Radian *rad2)
{
	unsigned int _op = op[1] ? op[0] + op[1] : op[0];
	switch(_op)
	{
	case '<':
		return *rad1 < *rad2;
	case '>':
		return *rad1 > *rad2;
	case '='*2:
		return *rad1 == *rad2;
	case '<'+'=':
		return *rad1 <= *rad2;
	case '>'+'=':
		return *rad1 >= *rad2;
	default:
		return false;
	}
}

extern "C" DLL_EXPORT Radian *opRadian_Radian_Binary_Float(Radian *rad, const char *op, float fl)
{
	unsigned int _op = op[1] ? op[0] + op[1] : op[0];
	switch(_op)
	{
	case '=':
		*rad = fl;
		return rad;
	case '*':
		return new Radian(*rad * fl);
	case '*'+'=':
		*rad *= fl;
		return rad;
	case '/':
		return new Radian(*rad / fl);
	case '/'+'=':
		*rad /= fl;
		return rad;
	default:
		return rad;
	}
}

extern "C" DLL_EXPORT float call_Radian_valueRadians(Radian* ptr)
{
	return ptr->valueRadians();
}

